<template>
	<view class="commission_record_container">
		<view class="my_commission_box">
			<!-- 当前佣金 -->
			<view class="commission_box" v-for="item in commissionList" :key="item.id" @click="handlerCommission(item)">
				<view class="commission_title">
					{{ item.title }}
				</view>
				<view class="commission_price" v-if="item.id == '0'">
					<span style="font-size: 20rpx;">￥</span>{{ personMsgObj.yj }}
				</view>
				<view class="commission_price" v-if="item.id == '1'">
					<span style="font-size: 20rpx;">￥</span>{{ userAccumulated }}
				</view>
				<view class="commission_price" v-if="item.id == '2'">
					<span style="font-size: 20rpx;">￥</span>{{ personMsgObj.yj }}
				</view>
				<view class="commission_btn">
					{{ item.tip }} >
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['personMsgObj', 'isShowWithdrawal', 'userAccumulated', 'userIsAgent', 'commissionList'],
		data() {
			return {
				// commissionList: [{
				// 		id: '0',
				// 		title: '当前佣金',
				// 		price: '',
				// 		tip: '佣金记录'
				// 	},
				// 	{
				// 		id: '1',
				// 		title: '累计提现',
				// 		price: '',
				// 		tip: '提现记录'
				// 	},
				// 	{
				// 		id: '2',
				// 		title: '可提现',
				// 		price: '',
				// 		tip: '申请提现'
				// 	},
				// ],
				isShowWithdrawalNew: '',
				userIsAgentNew: ''
			}
		},
		watch: {
			isShowWithdrawal: {
				handler(newVal) {
					this.isShowWithdrawalNew = newVal
				},
				immediate: true
			},

			userIsAgent: {
				handler(newVal) {
					this.userIsAgentNew = newVal
				},
				immediate: true
			}
		},
		onShow() {
			// this.moveterConfig()
		},
		methods: {
			// 判断用户是否实名认证接口
			checkRealName() {
				const that = this
				this.$request('/api/checkRealName', {}, 'POST').then(res => {
					if (res.data == 0) {
						// 未实名
						if (that.userIsAgentNew == 0) {
							uni.navigateTo({
								url: "/pages/my/withdrawal/noRealName",
							});
						} else {
							uni.navigateTo({
								url: "/pages/agentPortion/my/withdrawal/noRealName",
							});
						}

					} else {
						// 已实名
						if (that.userIsAgentNew == 0) {
							uni.navigateTo({
								url: "/pages/my/withdrawal/withdrawal",
							});
						} else {
							uni.navigateTo({
								url: "/pages/agentPortion/my/withdrawal/withdrawal",
							});
						}
					}
				})
			},

			// 点击佣金记录
			handlerCommission(val) {
				if (val.title == "当前佣金") {
					if (this.userIsAgentNew == 0) {
						// 分销员
						uni.navigateTo({
							url: "/pages/my/kickbackRecord/kickbackRecord",
						});
					} else {
						// 合伙人
						uni.navigateTo({
							url: "/pages/agentPortion/my/kickbackRecord/kickbackRecord",
						});
					}

				} else if (val.title == "累计提现") {
					if (this.userIsAgentNew == 0) {
						uni.navigateTo({
							url: "/pages/my/accWithdrawal/accWithdrawal",
						});
					} else {
						uni.navigateTo({
							url: "/pages/agentPortion/my/accWithdrawal/accWithdrawal",
						});
					}

				} else if (val.title == "可提现") {
					if (this.isShowWithdrawalNew == false) {
						return;
					} else {
						this.checkRealName();
						// uni.navigateTo({
						// 	url: '/pages/my/withdrawal/withdrawal'
						// })
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.commission_record_container {

		.my_commission_box {
			display: flex;
			justify-content: space-between;
			background: #FFFFFF;
			box-shadow: 0px 5rpx 17rpx 1px rgba(172, 168, 168, 0.15);
			border-radius: 10rpx;
			margin: 0 18rpx;

			.commission_box {
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				padding: 20rpx 19rpx;

				.commission_title {
					font-family: all-font;
					font-weight: 400;
					font-size: 24rpx;
					color: #808080;
				}

				.commission_price {
					font-family: my-font;
					font-weight: 500;
					font-size: 30rpx;
					color: #333333;
					padding: 12rpx 0 10rpx;
				}

				.commission_btn {
					background: #FF6060;
					border-radius: 50rpx;
					font-family: my-font;
					font-weight: 400;
					font-size: 19rpx;
					color: #FFFFFF;
					padding: 3rpx 4rpx;
				}
			}
		}
	}
</style>